package encdb

import (
	"fhe-search-cloud/models"

	"github.com/jmoiron/sqlx"
)

func AddOneEncDocument(tx *sqlx.Tx, encDoc *models.EncDocument) (encDocId int) {
	_, err := tx.NamedExec("INSERT INTO enc_documents (enc_title, enc_file_type, enc_file_path) VALUES (:enc_title, :enc_file_type, :enc_file_path)", encDoc)
	if err != nil {
		panic(err)
	}
	tx.Get(&encDocId, "SELECT LAST_INSERT_ID();")
	return encDocId
}
